package com.thekernel.service.impl;

import com.thekernel.dao.AdminDao;
import com.thekernel.dao.impl.AdminDaoImpl;
import com.thekernel.entity.Admin;

public class AdminServiceImpl {
	
	private AdminDao admindao = new AdminDaoImpl();
	public boolean login(Admin admin) {
		boolean result = false;
		Admin realadmin = admindao.selectByUsername(admin.getUsername());
		if(realadmin!=null){
			if(realadmin.getPassword().equals(admin.getPassword())){
				result=true;
			}
		}
		return result;
	}

	public int reg(Admin admin) {
		int result=0;
		Admin realadmin = admindao.selectByUsername(admin.getUsername());
		if(realadmin==null){
			result = admindao.insertAdmin(admin);
		}
		else{
			result = -1;
		}
		return result;
	}

}
